namespace Shumei.EFCore.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addCourseStudy2 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CourseStudyRecords",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        hasLearnEnd = c.Int(nullable: false),
                        courseVideo_Id = c.Int(),
                        user_account = c.String(maxLength: 20, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CourseVideos", t => t.courseVideo_Id)
                .ForeignKey("dbo.Users", t => t.user_account)
                .Index(t => t.courseVideo_Id)
                .Index(t => t.user_account);
            
            CreateTable(
                "dbo.CourseStudies",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SubscriberTime = c.DateTime(nullable: false, precision: 0),
                        course_Id = c.Int(),
                        user_account = c.String(maxLength: 20, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Courses", t => t.course_Id)
                .ForeignKey("dbo.Users", t => t.user_account)
                .Index(t => t.course_Id)
                .Index(t => t.user_account);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.CourseStudies", "user_account", "dbo.Users");
            DropForeignKey("dbo.CourseStudies", "course_Id", "dbo.Courses");
            DropForeignKey("dbo.CourseStudyRecords", "user_account", "dbo.Users");
            DropForeignKey("dbo.CourseStudyRecords", "courseVideo_Id", "dbo.CourseVideos");
            DropIndex("dbo.CourseStudies", new[] { "user_account" });
            DropIndex("dbo.CourseStudies", new[] { "course_Id" });
            DropIndex("dbo.CourseStudyRecords", new[] { "user_account" });
            DropIndex("dbo.CourseStudyRecords", new[] { "courseVideo_Id" });
            DropTable("dbo.CourseStudies");
            DropTable("dbo.CourseStudyRecords");
        }
    }
}
